package gazpachito.examples.patterns.methodTemplate.factory;

import gazpachito.examples.patterns.methodTemplate.business.TemplateBusiness;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component("TemplateServiceLocator")
public class TemplateServiceLocator {

	@Autowired
	private ApplicationContext applicationContext;

	@SuppressWarnings("rawtypes")
	public TemplateBusiness getTemplate(String template) {
		TemplateBusiness templateBusiness = null;
		if (!StringUtils.isBlank(template)) {
			templateBusiness = (TemplateBusiness) applicationContext
					.getBean(template);
		}
		return templateBusiness;
	}
}
